package tyk.common;


import lombok.Data;

/*
* 封装的统一返回值类
* */
@Data
public class Result<T> {

    private Integer code;  //响应值
    private String msg;    //错误提示信息
    private T data;        //封装返回给前端的数据

    /*
    * 响应成功的封装方法
    * */
    public static <T> Result<T> success(T data) {

        Result<T> result = new Result<>();
        result.code = 200;
        result.data = data;
        return result;
    }

    /*
    * 响应失败的封装方法
    * */
    public static Result<String> error(String msg) {

        Result<String> result = new Result<>();
        result.code = 201;
        result.msg = msg;
        return result;
    }
}
